/*
 *  POJ2632: Crashing Robots
 */

/*-------- Includes --------*/
#include <iostream>
#include <cstring>

using namespace std;

/*-------- Types --------*/
struct Robot {
    int  x, y;
    char d;
};

/*-------- Global Variable --------*/
const char direction[4] = {'E', 'S', 'W', 'N'};

/*-------- Function Prototypes --------*/
int dirToNum(char c);

/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int nOfCase;

    cin >> nOfCase;

    while (nOfCase--) {
        int width, height;  // width: length of EW, height: length of NS
        int n, m;           // n: number of robots, m: number of instructions

        cin >> width >> height;
        cin >> n     >> m;

        int map[width * height];

        memset(map, 0, sizeof(map));

        Robot robots[n];

        Robot *p = robots;
        for (int i = 0; i < n; i++, p++) {
            cin >> p->x >> p->y >> p->d;
            p->x--;
            p->y--;
            map[p->x + p->y * width] = i + 1;
        }

        bool crashed = false;
        for (int i = 0; i < m; i++) {
            int  index, repeat;
            char action;

            cin >> index >> action >> repeat;

            if (crashed) continue;

            p = robots + index - 1;

            if (action == 'F') {        // go ahead
                map[p->x + p->y * width] = 0;
                switch (p->d) {
                case 'E':
                    while (repeat--) {
                        p->x++;
                        if (p->x == width || map[p->x + p->y * width] > 0) {
                            crashed = true;
                            break;
                        }
                    }
                    break;
                case 'W':
                    while (repeat--) {
                        p->x--;
                        if (p->x == -1 || map[p->x + p->y * width] > 0) {
                            crashed = true;
                            break;
                        }
                    }
                    break;
                case 'N':
                    while (repeat--) {
                        p->y++;
                        if (p->y == height || map[p->x + p->y * width] > 0) {
                            crashed = true;
                            break;
                        }
                    }
                    break;
                case 'S':
                    while (repeat--) {
                        p->y--;
                        if (p->y == -1 || map[p->x + p->y * width] > 0) {
                            crashed = true;
                            break;
                        }
                    }
                    break;
                }

                if (crashed) {   // crash, then print information
                    if (p->x == -1 || p->x == width || p->y == -1 || p->y == height)
                        cout << "Robot " << index << " crashes into the wall" << endl;
                    else
                        cout << "Robot " << index << " crashes into robot " << map[p->x + p->y * width] << endl;
                } else          {   // no crash, then update map
                    map[p->x + p->y * width] = index;
                }
            } else if (action == 'L') { // turn left
                int num = dirToNum(p->d);

                num -= repeat % 4;
                if (num < 0) num += 4;

                p->d = direction[num];
            } else {                    // turn right
                int num = dirToNum(p->d);

                num += repeat;
                num %= 4;

                p->d = direction[num];
            }
        }

        if (!crashed) cout << "OK" << endl;
    }

    return 0;
}

/*-------- Functions --------*/
int dirToNum(char c) {
    switch (c) {
        case 'E': return 0;
        case 'S': return 1;
        case 'W': return 2;
        case 'N': return 3;
        default : break;
    }

    return -1;
}
